home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / FNTPAK32.ZIP / C.EXE / DEMO_GFX.C < prev    next >
C/C++ Source or Header  |  1995-08-16  |  4KB  |  127 lines

  1. /********************************************************************
  2.     Demo_GFX.C                  Copyright 1994, Rob W. Smetana
  3.  
  4.     Turn Screen Swapping ON if appropriate.
  5.  
  6.     Demonstrate how to:
  7.  
  8.      1.  Detect monitor type.  We need EGA/VGA to change fonts.
  9.  
  10.      2.  Change fonts in GRAPHICS modes.
  11.  
  12.     Requires:
  13.      a.  Graphics.Lib
  14.      1.  Video.Obj     (which contains function GetMonitor)
  15.      2.  Font_GFX.OBJ  (graphics-mode default font routines)
  16.      3.  Script1.OBJ   (graphics- AND text-mode custom Script font)
  17.  
  18. ********************************************************************/
  19.  
  20. #include <graph.h>
  21. #include <dos.h>
  22. #include <font_pak.h>
  23.  
  24. /* GetMonitor function is in video_c.obj */
  25.  
  26. extern int GetMonitor ();
  27. void video_mode(int mode);
  28.  
  29. /* prototype for our callable Script font */
  30. void extern pascal far SCRIPT1(int Block);
  31. void extern pascal far GFXSCRIPT1(void);
  32.  
  33. int FontSize ();                /* local get-monitor function to detect EGA/VGA
  34.                                    and return size of default font (14/16)
  35.                                    -or- print error message if appropriate
  36.                                 */
  37.  
  38. int main (void)
  39. {
  40.     int FSize, n;
  41.  
  42.     FSize = FontSize ();        /* FontSize returns 14, 16 or 0 (no EGA/VGA) */
  43.  
  44.     if (FSize == 0)             /* Bail out if no EGA/VGA */
  45.        return (-99);
  46.  
  47.     _setvideomode(_TEXTC80);
  48.  
  49.     printf("               Demonstrates CALLing fonts in Graphics Modes.\n");
  50.     printf("             These are the same fonts you can use in text mode.\n\n");
  51.     printf("        Press a key and we'll demonstrate several FONT SIZES at once!");
  52.     getch ();
  53.  
  54.     _setvideomode(_ERESCOLOR);
  55.  
  56.      for (n = 1; n < 15; ++n)
  57.     {
  58.         GFXFont08();
  59.        printf (" Here's the default 8x8,");
  60.         GFXSCRIPT1();
  61.        printf (" an 8x16 SCRIPT font,");
  62.        GFXFont14();
  63.        printf (" and the 8x14--on the SAME LINE!\n");
  64.  
  65.  
  66.     }
  67.  
  68.     printf ("\n\n\n\n");
  69.  
  70.     GFXFont14();
  71.  
  72.     printf ("   Note how easily you can change fonts in graphics -or- text modes.  Also\n");
  73.     printf ("   note that THREE fonts are printed on the SAME LINE above!  But since font\n");
  74.     printf ("   heights differ, line heights differ as well.\n\n");
  75.  
  76.     printf ("   Down here is the 8x14 font.  So you're looking at 3 font sizes (8x8,\n");
  77.     printf ("   8x14 and 8x16) -- ALL ON THE SAME SCREEN!");
  78.  
  79.     getch ();
  80.  
  81.     _setvideomode(_DEFAULTMODE);
  82.  
  83. }   /* end main */
  84.  
  85. /*******************************************************************
  86.  Function:  FontSize
  87.  
  88.  Purpose:   Check for EGA/VGA and return 14 (EGA 8x14), 16 (VGA 8x16)
  89.             or 0 if we're not using an EGA/VGA
  90.  
  91.             Print error message and end if no EGA/VGA
  92.  
  93. GetMonitor returns an integer (0 - 8) indicating the type of monitor
  94.            in use.  If two monitors are being used, GetMonitor returns
  95.            the type of the primary monitor.
  96.  
  97.            0 = None (no monitor)    3 = EGA (or MultiSync)
  98.            4 = Color (CGA)          5 = Monochrome
  99.            7 = VGA Monochrome       8 = VGA Color (or MultiSync)
  100.  
  101. *******************************************************************/
  102.  
  103. int FontSize ()
  104.  
  105. {
  106.     int MonType;
  107.     MonType = GETMONITOR();
  108.  
  109.     switch (MonType)  {
  110.        case 0, 4, 5:        /* no monitor, Mono or CGA */
  111.          printf ("Sorry.  An EGA or VGA monitor is required to run this demo. \n\n");
  112.          return (0);
  113.          break;
  114.        case 3:              /* EGA.  Set fontsize to 8x14 */
  115.          return (14);
  116.          break;
  117.        case 7, 8:           /* VGA.  Set fontsize to 8x16 */
  118.          return (16);
  119.          break;
  120.        default:
  121.          printf ("Unknown monitor type.  Sorry.  An EGA or VGA monitor is required to run this. \n\n");
  122.          return (0);
  123.          break;
  124.     }
  125. }
  126.  
  127.